<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="vo.*,Dao.*,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<title>商品查询</title>
<!-- Bootstrap 核心CSS -->
<link rel="stylesheet" href="https://code.z01.com/v4/dist/css/bootstrap.min.css">
<style>
/* * Globals */
/* Links */
a, a:focus, a:hover { color: #fff; }
/* Custom default button */
.btn-secondary, .btn-secondary:hover, .btn-secondary:focus { color: #333; text-shadow: none; /* Prevent inheritance from `body` */ background-color: #fff; border: .05rem solid #fff; }
/* * Base structure */
html, body { height: 100%; background-color: #333; }
body { color: #fff; text-align: center; text-shadow: 0 .05rem .1rem rgba(0,0,0,.5); }
/* Extra markup and styles for table-esque vertical and horizontal centering */
.site-wrapper { display: table; width: 100%; height: 100%; /* For at least Firefox */ min-height: 100%; box-shadow: inset 0 0 5rem rgba(0,0,0,.5); }
.site-wrapper-inner { display: table-cell; vertical-align: top; }
.cover-container { margin-right: auto; margin-left: auto; }
/* Padding for spacing */
.inner { padding: 2rem; }
/* * Header */
.masthead { margin-bottom: 2rem; }
.masthead-brand { margin-bottom: 0; }
.nav-masthead .nav-link { padding: .25rem 0; font-weight: 700; color: rgba(255,255,255,.5); background-color: transparent; border-bottom: .25rem solid transparent; }
.nav-masthead .nav-link:hover, .nav-masthead .nav-link:focus { border-bottom-color: rgba(255,255,255,.25); }
.nav-masthead .nav-link + .nav-link { margin-left: 1rem; }
.nav-masthead .active { color: #fff; border-bottom-color: #fff; }

@media (min-width: 48em) {
.masthead-brand { float: left; }
.nav-masthead { float: right; }
}
/* * Cover */
.cover { padding: 0 1.5rem; }
.cover .btn-lg { padding: .75rem 1.25rem; font-weight: 700; }
/* * Footer */
.mastfoot { color: rgba(255,255,255,.5); }
/* * Affix and center */
@media (min-width: 40em) {
/* Pull out the header and footer */
.masthead { position: fixed; top: 0; }
.mastfoot { position: fixed; bottom: 0; }
/* Start the vertical centering */
.site-wrapper-inner { vertical-align: middle; }
/* Handle the widths */
.masthead,  .mastfoot,  .cover-container { width: 100%; /* Must be percentage or pixels for horizontal alignment */ }
}
@media (min-width: 62em) {
.masthead,  .mastfoot,  .cover-container { width: 42rem; }
}
</style>
<%
request.setCharacterEncoding("utf-8");
//String tic = request.getParameter("tic");
//out.print(tic);

%>
</head>
<body background="../pic/333.jpg" style="background-size:100%;">
<div class="site-wrapper">
  <div class="site-wrapper-inner">
    <div class="cover-container">
      <header class="masthead clearfix">
        <div class="inner">
          <h6 class="masthead-brand">Power By &nbsp</h6>
          <h3 class="masthead-brand">GSC</h3>
          <nav class="nav nav-masthead"> 
          <a class="nav-link " href="#">分类：</a> 
          <a class="nav-link" id="a" href="goos_fenlei.jsp?tic=1">电子产品</a> 
          <a class="nav-link" id="b" href="goos_fenlei.jsp?tic=2">服饰</a> 
          <a class="nav-link" id="c" href="goos_fenlei.jsp?tic=3">日用品</a>
          <a class="nav-link" id="d" href="goos_fenlei.jsp?tic=4">食品</a> 
          <a class="nav-link" href="Zhuye.jsp">Exit</a> 
          </nav>
        </div>
      </header>
      <main role="main" class="inner cover" style="margin-left:-70px;">
      <h1 class="cover-heading" style="margin-left:-500px;">商品列表：</h1>
     
      
       
       <div class="row" style="width:800px;">
        <%
      Gooddao dao = new Gooddao();

      int i=0;


      String thispage = request.getParameter("thispage");

      int thispage2;
      if(thispage==null){
      	thispage2 = 0;
      }else{
      	thispage2 = Double.valueOf(thispage).intValue();
      }
      if(thispage2 < 0){
      	thispage2 = 0;
      }


      ArrayList<Goods> list2 = dao.do_Select();
      double listsize=list2.size();
      double listsize2 = Math.ceil(listsize/3.0)*3-3;

      if(thispage2>listsize2){
      	thispage2 = (int)listsize2;
      }

      int listsize3=(int)listsize2/3+1;

      String p = thispage2/3+1+"/"+listsize3+"页";


      ArrayList<Goods> list = dao.do_Select_bypage(thispage2);
      Iterator<Goods> it = list.iterator(); 
  	  while(it.hasNext()){
		Goods goo = it.next();
		
      %>
            <div class="col-md-4" >
              <div class="card mb-4 box-shadow">
                <img class="card-img-top" alt="Thumbnail [100%x225]" style="height: 225px; width: 100%; display: block;" src="../pic/<%=goo.getGood_pic() %>" data-holder-rendered="true">
                <div class="card-body" >
                  <p class="card-text" style="color:black;">名称：<%=goo.getGood_name() %><br>简介：<%=goo.getGood_desc()%><br></p>
                  <div class="d-flex justify-content-between align-items-center">
                    <div class="btn-group">
                      <button type="button" class="btn btn-sm btn-info">查看</button>
                      <%
                      if(goo.getType_id()==1){
                      %>
                      <a  class="btn btn-sm btn-warning" href="type_change.jsp?id=<%=goo.getGood_id()%>&tic=0">下架</a>
                      <%
                      }else if(goo.getType_id()==0){
                      %>
                      <a class="btn btn-sm btn-warning" href="type_change.jsp?id=<%=goo.getGood_id()%>&tic=1">上架</a>
                      <%
                      }
                      %>
                       <a class="btn btn-sm btn-danger" href="good_delete.jsp?id=<%=goo.getGood_id()%>" onclick="panduan()">删除</a>
                    </div>
                    <small class="text-muted">价格：<%=goo.getGood_price() %>￥ <br>库存：<%=goo.getQty() %></small>
                  </div>
                </div>
              </div>
            </div>
            
      <%
  	}
      %>
     </div>  
       
    
      
          
            
<a href="goos_fenlei.jsp?thispage=0" class="btn btn-outline-light" style="margin-left:50px;">首页</a>
<a href="goos_fenlei.jsp?thispage=<%=thispage2-3 %>" class="btn btn-outline-light" >上一页</a>
<a href="goos_fenlei.jsp?thispage=<%=thispage2+3 %>" class="btn btn-outline-light" >下一页</a>
<a href="goos_fenlei.jsp?thispage=<%=listsize2 %>" class="btn btn-outline-light" >尾页</a>
<a href="#" class="btn btn-outline-light" style="margin-left:20px;"><%=p %></a><br><br>

      <a class="btn btn-outline-info" href="shangjia.jsp" role="button" style="width:500px;font-size:20px;margin-left:50px;">上架新商品</a>
      </main>
      
    </div>
  </div>
</div>


<!-- Bootstrap 核心 JavaScript --> 
<script src="https://code.z01.com/js/jquery-3.2.1.slim.min.js"></script>
<script src="https://code.z01.com/v4/dist/js/popper.min.js"></script>
<script src="https://code.z01.com/v4/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
function panduan(){
	if (!confirm("确认要删除吗？")) { 
        window.event.returnValue = false;
    }
   
}
</script>
</body></html>